<layout name="Common/layout" />

<link rel="stylesheet" href="__PUBLIC__/Home/style/cart.css" type="text/css">
<script type="text/javascript" src="__PUBLIC__/Home/js/cart1.js"></script>

<!-- 页面头部 start -->
<div class="header w990 bc mt15">
	<div class="logo w990">
		<h2 class="fl"><a href="index.html"><img src="__PUBLIC__/Home/images/logo.png" alt="京西商城"></a></h2>
		<div class="flow fr">
			<ul>
				<li class="cur">1.我的购物车</li>
				<li>2.填写核对订单信息</li>
				<li>3.成功提交订单</li>
			</ul>
		</div>
	</div>
</div>
<!-- 页面头部 end -->

<div style="clear:both;"></div>

<!-- 主体部分 start -->
<form action="__ACTION__" method="post" id="cart_form">
	<div class="mycart w990 mt10 bc">
		<h2><span>我的购物车</span></h2>
		<table>
			<thead>
			<tr>
				<th class="col1">商品名称</th>
				<th class="col2">商品信息</th>
				<th class="col3">单价</th>
				<th class="col4">数量</th>
				<th class="col5">小计</th>
				<th class="col6">操作</th>
			</tr>
			</thead>
			<tbody>
			<?php
				$tp = 0; // 总价
				foreach ($data as $k => $v): ?>
			<tr>
				<td class="col1"><a href=""><?php showImage($v['mid_logo']); ?></a>
					<strong><a href="<?php echo U('Index/goods?id='.$v['goods_id']); ?>"><?php echo $v['goods_name']; ?></a></strong></td>
				<td class="col2">
					<?php foreach ($v['gaData'] as $k1 => $v1): ?>
					<p><?php echo $v1['attr_name']; ?>：<?php echo $v1['attr_value']; ?></p>
					<?php endforeach; ?>
				</td>
				<td class="col3">￥<span><?php echo $v['price']; ?>元</span></td>
				<td class="col4">
					<a href="javascript:;" class="reduce_num"></a>
					<input type="text" name="goods_number[<?php echo $v['id']; ?>]" value="<?php echo $v['goods_number']; ?>" class="amount"/>
					<a href="javascript:;" class="add_num"></a>
				</td>
				<td class="col5">￥<span><?php $xj = $v['price'] * $v['goods_number'];$tp+=$xj;echo $xj; ?></span></td>
				<td class="col6"><a href="">删除</a></td>
			</tr>
			<?php endforeach; ?>
			</tbody>
			<tfoot>
			<tr>
				<td colspan="6">购物金额总计： <strong>￥ <span id="total"><?php echo $tp; ?></span></strong></td>
			</tr>
			</tfoot>
		</table>
		<div class="cart_btn w990 bc mt10">
			<a href="/" class="continue">继续购物</a>
			<a href="<?php echo U('Order/add'); ?>" class="checkout">结 算</a>
		</div>
	</div>
	<!-- 主体部分 end -->
</form>

<script type="text/javascript">
	function updateCart(car_id, goods_number) {
		var status = false;
		$.ajax({
			url:"<?php echo U('Cart/update_cart');?>",
			type:'post',
			data:car_id+'='+goods_number,
			dataType:'json',
			async:false,
			success:function(data){
				if(data.status==1){
					status = true;
				} else {
					alert(data.info);
				}
			}
		});
		return status;
	}
</script>